<template>
  <div class="index-detail">
    <Header></Header>
    <div class="mains">
      <div v-if='data.length !=0 ' style="background:#fff;">
          <div v-if='data.chrContentType == 5'  v-html="data.varContent" style="margin:10px 0;" ></div>
          <el-button class='sure' v-if='data.chrContentType == 6' @click='goDown'>下载</el-button>
          <iframe  v-if='data.chrContentType == 6' :src="iframeUrl" frameborder="0"></iframe>
         
      </div>
    </div>
     <Footer></Footer>
  </div>
</template>

<script>
import config from "../../config.js";
import Header from '../common/header'
import Footer from '../common/footer'
export default {
  data () {
    return {
      data:{},
      iframeUrl:''
    };
  },
   components: {
    Header,
    Footer
  },
  created () {
    this.getList()
  },
  methods: {
    goDown(){
          this.$axios
          ({
            method: 'post',
              url: "http://yjyaapi-sit.bosafe.com/emergency/downLoad?id="+this.data.attachmentList[0],
          }).then(
              (res)=>{
                  if(res.data.meta.success){
										if(res.data.meta.message){
											window.location.href=res.data.data
										}else{
											this.$message.warning('下载文件为空')
										}
									}else{
									
										this.$message.warning(res.data.meta.message)
									}
              }
          )
      },
    getList(){
       this.$axios
        .get(config.baseUrl2 + "specialSubjectInfo?intId="+this.$route.query.id)
        .then(res => {
          if (!res.data.code) {
            this.data = res.data
            if(res.data.chrContentType == 6){
                this.getViewPath(res.data.attachmentList[0])
            }
          } else {
            this.$message.warning(res.data.msg);
          }
        })
        .catch(response => {
          console.log(response);
        });
    },
    getViewPath(n){
       this.$axios
        .get(config.baseUrl2 + "getViewPath?fid="+n)
        .then(res => {
          if (res.data.code == 0) {
            this.iframeUrl = res.data.viewPath
          } else {
            this.$message.warning(res.data.msg);
          }
        })
        .catch(response => {
          console.log(response);
        });
    }
  }
};
</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang='less' scoped>
.index-detail{
   height: 100%;
  width: 100%;
  position: relative;
  .header{
    position: fixed;
    top: 0;
    width:100%;
  }
   .mains{
    width:1100px;
    margin:0 auto;
    min-height:100%;
    padding:58px 20px 40px 20px;
   .sure {
    margin:10px 10px 10px 0;
    width:80px;
    background: #4080ff;
   /* background-image: linear-gradient(90deg, #6eb1ff 20%, #3372ff 80%);*/
    border: 0;
    border-radius: 8px;
    color:#fff;
    position: absolute;
    top:60px;
    right:160px;
    }
    .sure:hover{
        opacity: .8;
        color:#fff;
    }
    iframe{
      position: absolute;
      height:calc(100% - 150px);
      top:120px;
      width:1100px;
      left:calc(50% - 550px);
    }
  }
  .login_footer {
    position: fixed;
    bottom: 5%;
    font-size: 12px;
    width: 100%;
    text-align: center;
    color: #888;
  }
}
</style>
